<template>
	<div>
		<div class="IRSbox">
			<div @click="openTable('table')"><span>关联IRS应用</span><el-button class="button" type="primary">选择关联应用</el-button></div>
			<div><span>IRS系统编目</span><el-button class="button" type="primary">前往IRS系统编目</el-button></div>
		</div>
		<!--关联IRS应用选择后出现tab-->
		<div></div>
		<el-tabs v-model="editableTabsValue" type="card" closable class="demo-tabs" @edit="handleTabsEdit">
			<el-tab-pane v-for="item in editableTabs" :key="item.name" :label="item.label" :name="item.name" class="el-tab-pane">
				<HyFormCopy ref="irsForm" :hyFormConfig="searchConfig" :hyFormDefault="searchDefault1" :hyFormFields="searchFields1"></HyFormCopy>
				<HyCard :title="hyCard2.title" class="HyCard-Card">
					<div class="formThree">
						<HyFormCopy
							ref="irsForm2"
							:hyFormConfig="searchConfig"
							:hyFormDefault="searchDefault2"
							:hyFormFields="searchFieldsCloudType"
						></HyFormCopy>
						<!--物理服务器（或集群）申请依据佐证材料-->
						<div class="form-choose" v-show="isPhysics">
							<div class="choose-right">
								<HyFormCopy
									ref="irsFormPhysics"
									:hyFormConfig="searchConfig"
									:hyFormDefault="searchDefaultPhysics"
									:hyFormFields="searchFieldsPhysics"
									class="HyFormCopy-box"
								></HyFormCopy>
							</div>

							<div class="uploadDiv-box">
								<span class="span-require">* </span>
								<span>佐证材料（上传佐证材料）</span>
								<el-upload
									v-model:file-list="physicsFilesList"
									class="upload-demo"
									:action="baseURL + '/admin/sys-file/upload'"
									multiple
									:before-upload="(file) => beforeUpload(file, fileList(2).accept)"
									:accept="fileList(2).accept"
									:headers="headers"
								>
									<el-button type="primary" icon="Upload">上传附件</el-button>
									<template #tip>
										<div class="el-upload__tip">
											<span class="span-require">*</span>
											{{ fileList(2).tips }}
										</div>
									</template>
								</el-upload>
							</div>
						</div>
						<!--租凭互联网云资源佐证材料-->
						<div class="form-choose" v-show="isLease">
							<div class="choose-right">
								<HyFormCopy
									ref="irsFormLease"
									:hyFormConfig="searchConfig"
									:hyFormDefault="searchDefaultLease"
									:hyFormFields="searchFieldsLease"
									class="HyFormCopy-box"
								></HyFormCopy>
							</div>

							<div class="uploadDiv-box">
								<span class="span-require">* </span>
								<span>佐证材料（上传佐证材料）</span>
								<el-upload
									v-model:file-list="leaseFilesList"
									class="upload-demo"
									:action="baseURL + '/admin/sys-file/upload'"
									multiple
									:before-upload="(file) => beforeUpload(file, fileList(2).accept)"
									:accept="fileList(2).accept"
									:headers="headers"
								>
									<el-button type="primary" icon="Upload">上传附件</el-button>
									<template #tip>
										<div class="el-upload__tip">
											<span class="span-require">*</span>
											{{ fileList(2).tips }}
										</div>
									</template>
								</el-upload>
							</div>
						</div>
						<!--政务私有云佐证材料-->
						<div class="form-choose" v-show="isGov">
							<div class="choose-right">
								<HyFormCopy
									ref="irsFormGov"
									:hyFormConfig="searchConfig"
									:hyFormDefault="searchDefaultGov"
									:hyFormFields="searchFieldsGov"
									class="HyFormCopy-box"
								></HyFormCopy>
							</div>

							<div class="uploadDiv-box">
								<span class="span-require">* </span>
								<span>佐证材料（上传佐证材料）</span>
								<el-upload
									v-model:file-list="govFilesList"
									class="upload-demo"
									:action="baseURL + '/admin/sys-file/upload'"
									multiple
									:before-upload="(file) => beforeUpload(file, fileList(2).accept)"
									:accept="fileList(2).accept"
									:headers="headers"
								>
									<el-button type="primary" icon="Upload">上传附件</el-button>
									<template #tip>
										<div class="el-upload__tip">
											<span class="span-require">*</span>
											{{ fileList(2).tips }}
										</div>
									</template>
								</el-upload>
							</div>
						</div>
					</div>
				</HyCard>
				<!--第一部分-->
				<HyCard :title="hyCard3.title" class="HyCard-Card">
					<HyFormCopy
						class="isForm"
						ref="irsForm3"
						:hyFormConfig="searchConfig"
						:hyFormDefault="searchDefault3"
						:hyFormFields="searchFields3"
					></HyFormCopy>
					<div class="IRSbox" v-if="isUsePublic">
						<div><span>拟使用数据信息表</span><el-button class="button" type="primary" @click="addNewTable()">新增拟使用数据</el-button></div>
					</div>
					<template v-if="isUsePublic">
						<addTable title="拟使用数据信息表"></addTable>
					</template>
					<HyFormCopy
						class="isForm"
						ref="irsForm4"
						:hyFormConfig="searchConfig"
						:hyFormDefault="searchDefault4"
						:hyFormFields="searchFields4"
					></HyFormCopy>
					<div class="IRSbox" v-if="isProduceData">
						<div><span>拟产生数据信息表</span><el-button class="button" type="primary" @click="addTableFormInput1">新增拟产生数据</el-button></div>
						<div><span></span><el-button class="button" type="primary">导入拟产生数据</el-button></div>
						<div>
							<span></span><el-button class="button" type="primary" link @click="downLoadFile('数字化应用拟产生数据信息表.xlsx')">模板下载</el-button>
						</div>
					</div>
					<!--黄色表格-->
					<div v-show="isProduceData">
						<TableFormInput
							ref="TableFormInputByData"
							:addNewTable="addNewTableList1"
							:classificationType="classificationType"
							class="TableFormInput"
							@deleteRow="deleteRow1"
						/>
					</div>
					<!-- <template v-if="isProduceData">
						
					</template> -->
					<!-- <el-button @click="logList()">打印</el-button> -->
				</HyCard>
				<!--第二部分-->
				<HyCard :title="hyCard4.title" class="HyCard-Card">
					<HyFormCopy
						class="isForm"
						ref="irsForm5"
						:hyFormConfig="searchConfig"
						:hyFormDefault="searchDefault5"
						:hyFormFields="searchFields5"
					></HyFormCopy>
					<div class="IRSbox" v-if="isUseComponent">
						<div><span>组件信息表</span><el-button class="button" type="primary" @click="addNewTable()">新增需要使用组件</el-button></div>
						<!-- <div><span>IRS系统编目</span><el-button class="button" type="primary">前往IRS系统编目</el-button></div> -->
					</div>
					<template v-if="isUseComponent">
						<addTable></addTable>
					</template>
					<HyFormCopy
						class="isForm"
						ref="irsForm6"
						:hyFormConfig="searchConfig"
						:hyFormDefault="searchDefault9"
						:hyFormFields="searchFields9"
					></HyFormCopy>
					<div class="IRSbox" v-if="isShareComponent">
						<div><span>组件信息表</span><el-button class="button" type="primary" @click="addTableFormInput2">新增产生组件</el-button></div>
						<div><span></span><el-button class="button" type="primary">导入组件信息</el-button></div>
						<div>
							<span></span><el-button class="button" type="primary" link @click="downLoadFile('数字化应用拟产生数据信息表.xlsx')">模板下载</el-button>
						</div>
					</div>
					<!--黄色表格-->
					<div v-show="isShareComponent">
						<TableFormInputZuJian ref="TableFormInputByDataZuJian" :addNewTable="addNewTableList2" class="TableFormInput" @deleteRow="deleteRow2" />
					</div>
				</HyCard>
				<!--资源硬件信息-->
				<HyCard :title="hyCard5.title" class="HyCard-Card">
					<HyFormCopy
						class="isForm"
						ref="irsForm7"
						:hyFormConfig="searchConfig"
						:hyFormDefault="searchDefault6"
						:hyFormFields="searchFields6"
					></HyFormCopy>
				</HyCard>
				<!--驾驶舱建设-->
				<HyCard :title="hyCard6.title" class="HyCard-Card">
					<HyFormCopy
						class="isForm"
						ref="irsForm8"
						:hyFormConfig="searchConfig"
						:hyFormDefault="searchDefault7"
						:hyFormFields="searchFields7"
					></HyFormCopy>
				</HyCard>
			</el-tab-pane>
		</el-tabs>
		<!--附件-->
		<HyCard :title="hyCard7.title" class="HyCard-Card">
			<div class="outDiv">
				<div class="uploadDiv">
					<span class="span-require">* </span>
					<span>正式书面函</span>
					<el-upload
						v-model:file-list="decCardListLetter"
						class="upload-demo"
						:action="baseURL + '/admin/sys-file/upload'"
						multiple
						:before-upload="(file) => beforeUpload(file, fileList(2).accept)"
						:accept="fileList(2).accept"
						:headers="headers"
					>
						<el-button type="primary" icon="Upload">上传附件</el-button>
						<template #tip>
							<div class="el-upload__tip"><span class="span-require">*</span>{{ fileList(2).tips }}</div>
						</template>
					</el-upload>
				</div>
				<!--上传-->
				<div class="uploadDiv">
					<!-- <span class="span-require">* </span> -->
					<span>请上传相关附件（材料作证：比如争取中央资金的方案和批复）</span>
					<el-upload
						v-model:file-list="decCardListOther"
						class="upload-demo"
						:action="baseURL + '/admin/sys-file/upload'"
						multiple
						:before-upload="(file) => beforeUpload(file, fileList(2).accept)"
						:accept="fileList(2).accept"
						:headers="headers"
					>
						<el-button type="primary" icon="Upload">上传附件</el-button>
						<template #tip>
							<div class="el-upload__tip">
								<!-- <span class="span-require">*</span> -->
								{{ fileList(2).tips }}
							</div>
						</template>
					</el-upload>
				</div>
			</div>
		</HyCard>
		<Dialog :dialogTitle="dialogTitle" :dialogTableVisible="dialogTableVisibleF" @closeDialog="closeDialog"></Dialog>
		<chooseApp
			:title="dialogTitle"
			:type="tableType"
			:searchFields="searchFieldsObjCom"
			:visible="openVisible"
			:tableColumns="appTableColumnsCom"
			@close="closeTable"
		></chooseApp>
	</div>
</template>

<script setup lang="ts">
import other from '/@/utils/other';
import HyCard from '/@/components/HyCard/index.vue';
import HyFormCopy from '/@/components/HyFormCopy/index.vue';
import HyTable from '/@/components/HyTable/index.vue';
import addTable from './addTable.vue';
import TableFormInput from './tableFormInput.vue';
import TableFormInputZuJian from './tableFormInputZuJian.vue';
import chooseApp from '../../chooseApp/index.vue';
import Dialog from '../../dialog/index.vue';
import UploadFile from './uploadFile.vue';
import TsyUploadFile from '/@/components/HyUpload/index.vue';
import type { TabsPaneContext } from 'element-plus';
import type { TabPaneName } from 'element-plus';
import { ElMessage, ElMessageBox } from 'element-plus';
import { Session } from '/@/utils/storage';
import { beforeUpload, isNull, fileList, downLoadFile } from '../hooks/index';
import { useDict } from '/@/hooks/dict';
const props = defineProps({
	firstTabList: {
		type: Object,
		default: () => {
			return {};
		},
	},
	declareSubmit: {
		type: Boolean,
		default: () => {
			return false;
		},
	},
});
const firstTabListData = ref();
const isDeclareSubmit = ref(false);
watch(
	() => props.firstTabList,
	(val) => {
		if (val) {
			firstTabListData.value = val;
			setList();
		}
	}
);
watch(
	() => props.declareSubmit,
	(val) => {
		if (val) {
			isDeclareSubmit.value = val;
		}
	}
);
const openVisible = ref(false);
const searchFieldsObj = ref({
	appName: {
		label: '应用名称',
		type: 'input',
	},
});
const searchFieldsObjCom = computed(() => {
	return searchFieldsObj.value;
});
const appTableColumns = ref([
	{ prop: 'appName', slot: 'singleSlot', width: 50, fixed: 'left' },
	{ prop: 'appName', slot: 'indexSlot' },
	{ prop: 'appName', label: '数字化应用名称' },
	{ prop: 'appCode', label: '数字化应用编码' },
	{ prop: 'appManagerName', label: '应用管理员' },
	{ prop: 'appManagerPhone', label: '管理员联系方式' },
	{ prop: 'buildOrgName', label: '开发部门' },
]);
const appTableColumnsCom = computed(() => {
	return appTableColumns.value;
});
const searchDefault1 = ref({
	irsName: '',
	irsCode: '',
	irsType: '',
	developType: [],
	throughLevel: [],
	businessDomain: '',
	synergy: '',
	synergyStructure: [],
	synergyDescription: '',
	userRange: [],
	protectionLevel: '',
	secretReview: '',
	secretLevel: '',
	domestic: '',
});
const searchDefault2 = ref({
	cloudType: [],
});
const searchDefaultPhysics = ref({
	physics: '',
});
const searchDefaultLease = ref({
	lease: '',
});
const searchDefaultGov = ref({
	gov: '',
});
const searchDefault3 = ref({
	usePublic: '',
});
const searchDefault4 = ref({
	produceData: '',
});
const searchDefault5 = ref({
	useComponent: '',
});
const searchDefault6 = ref({
	hardware: '',
	hardwareType: '',
	strong: '',
	relevance: '',
});
const searchDefault7 = ref({
	cockpit: '',
	budget: 0,
});
const searchDefault9 = ref({
	shareComponent: '',
});
const setList = () => {
	editableTabs.value[0].label = firstTabListData.value?.irsName;
	addTableFormInputData.value.application = firstTabListData.value?.irsName;
	addTableFormInputData.value.applicationCode = firstTabListData.value?.irsCode;
	const developType = (firstTabListData.value.developType && firstTabListData.value.developType.split(',')) || [];
	const userRange = (firstTabListData.value.userRange && firstTabListData.value.userRange.split(',')) || [];
	const synergyStructure = (firstTabListData.value.synergyStructure && firstTabListData.value.synergyStructure.split(',')) || [];
	const throughLevel =
		(firstTabListData.value.throughLevel &&
			firstTabListData.value.throughLevel.split(',').filter((item) => {
				return item !== '';
			})) ||
		[];
	if (
		(firstTabListData.value.protectionLevel && firstTabListData.value.protectionLevel == '3') ||
		firstTabListData.value.protectionLevel == '4' ||
		firstTabListData.value.protectionLevel == '5'
	) {
		searchFields1.value.secretReview.type = 'select';
	} else {
		searchFields1.value.secretReview.type = '';
	}
	searchFields1.value.secretLevel.type = firstTabListData.value.secretReview && firstTabListData.value.secretReview == '1' ? 'select' : '';
	if (!firstTabListData.value.produceInfo.length) {
		addNewTableList1.value = firstTabListData.value.produceInfo;
		classificationType.value = '';
	} else {
		const tableInputData = firstTabListData.value.produceInfo[0];
		const data = {
			...tableInputData,
			classification: tableInputData.classification?.toString(),
			domain: tableInputData.domain?.toString(),
			level: tableInputData.level?.toString(),
		};
		addNewTableList1.value = [data];
		classificationType.value = data.classification;
	}
	if (!firstTabListData.value.shareComponentInfo.length) {
		addNewTableList2.value = firstTabListData.value.shareComponentInfo;
	} else {
		const tableInputData = firstTabListData.value.shareComponentInfo[0];
		const data = {
			...tableInputData,
			areas: tableInputData.areas?.toString(),
			componentType: tableInputData.componentType?.toString(),
			location: tableInputData.location?.toString(),
		};
		addNewTableList2.value = [data];
	}
	const NO1 = {
		irsName: firstTabListData.value?.irsName,
		irsCode: firstTabListData.value?.irsCode,
		irsType: isNull(firstTabListData.value?.irsType),
		throughLevel: throughLevel,
		businessDomain: isNull(firstTabListData.value?.businessDomain),
		synergy: isNull(firstTabListData.value?.synergy),
		protectionLevel: isNull(firstTabListData.value?.protectionLevel),
		domestic: isNull(firstTabListData.value?.domestic),
		secretReview: firstTabListData.value?.secretReview,
		secretLevel: firstTabListData.value?.secretLevel,
		synergyDescription: firstTabListData.value?.synergyDescription,
		developType: developType,
		userRange: userRange,
		synergyStructure: synergyStructure,
	};
	searchFields1.value.synergyStructure.type = firstTabListData.value && firstTabListData.value.synergy == '1' ? 'tag' : '';
	searchFields1.value.synergyDescription.type = firstTabListData.value && firstTabListData.value.synergy == '1' ? 'textarea' : '';
	const cloudType = (firstTabListData.value.cloudType && firstTabListData.value.cloudType.split(',')) || [];
	isPhysics.value = cloudType.includes('3') ? true : false;
	isLease.value = cloudType.includes('4') ? true : false;
	isGov.value = cloudType.includes('5') ? true : false;
	const NO2 = {
		cloudType: cloudType,
	};
	const NOsearchDefaultPhysics = {
		physics: firstTabListData.value?.physics || '',
	};
	const NOsearchDefaultLease = {
		lease: firstTabListData.value?.lease || '',
	};
	const NOsearchDefaultGov = {
		gov: firstTabListData.value?.gov || '',
	};
	imgList.value = {
		physicsFiles: firstTabListData.value.physicsFiles || [],
		leaseFiles: firstTabListData.value.leaseFiles || [],
		govFiles: firstTabListData.value.govFiles || [],
	};
	physicsFilesList.value = firstTabListData.value.physicsFiles.length ? firstTabListData.value.physicsFiles : [];
	leaseFilesList.value = firstTabListData.value.leaseFiles.length ? firstTabListData.value.leaseFiles : [];
	govFilesList.value = firstTabListData.value.govFiles.length ? firstTabListData.value.govFiles : [];
	decCardListLetter.value = firstTabListData.value.letter.length ? firstTabListData.value.letter : [];
	decCardListOther.value = firstTabListData.value.other.length ? firstTabListData.value.other : [];
	const NO3 = {
		usePublic: isNull(firstTabListData.value?.usePublic),
	};
	isUsePublic.value = firstTabListData.value?.usePublic == '1' ? true : false;
	const NO4 = {
		produceData: isNull(firstTabListData.value?.produceData),
	};
	isProduceData.value = firstTabListData.value?.produceData == '1' ? true : false;
	const NO5 = {
		useComponent: isNull(firstTabListData.value?.useComponent),
	};
	isUseComponent.value = firstTabListData.value?.useComponent == '1' ? true : false;
	const NO9 = {
		shareComponent: isNull(firstTabListData.value?.shareComponent),
	};
	isShareComponent.value = firstTabListData.value?.shareComponent == '1' ? true : false;
	const NO6 = {
		hardware: isNull(firstTabListData.value?.hardware),
		hardwareType: firstTabListData.value?.hardwareType || '',
		strong: isNull(firstTabListData.value?.strong),
		relevance: firstTabListData.value?.relevance || '',
	};
	searchFields6.value.hardwareType.type = firstTabListData.value.hardware == '1' ? 'textarea' : '';
	searchFields6.value.relevance.type = firstTabListData.value.strong == '1' ? 'textarea' : '';
	const NO7 = {
		cockpit: isNull(firstTabListData.value?.cockpit),
		budget: isNull(firstTabListData.value?.budget),
	};
	searchFields7.value.budget.type = firstTabListData.value.cockpit == '1' ? 'inputNumber' : '';
	searchDefault1.value = { ...NO1 };
	searchDefault2.value = { ...NO2 };
	searchDefaultPhysics.value = { ...NOsearchDefaultPhysics };
	searchDefaultLease.value = { ...NOsearchDefaultLease };
	searchDefaultGov.value = { ...NOsearchDefaultGov };
	searchDefault3.value = { ...NO3 };
	searchDefault4.value = { ...NO4 };
	searchDefault5.value = { ...NO5 };
	searchDefault6.value = { ...NO6 };
	searchDefault7.value = { ...NO7 };
	searchDefault9.value = { ...NO9 };
};
//三个上传分别对应物理服务器（或集群）申请依据
const imgList = ref({
	physicsFiles: [],
	leaseFiles: [],
	govFiles: [],
});
const headers = computed(() => {
	return {
		Authorization: 'Bearer ' + Session.get('token'),
		'TENANT-ID': Session.getTenant(),
	};
});
const isPhysics = ref(false);
const isLease = ref(false);
const isGov = ref(false);
const physicsFilesList = ref([]);
const leaseFilesList = ref([]);
const govFilesList = ref([]);
//上传
const decCardListLetter = ref([]);
const decCardListOther = ref([]);

const searchConfig = ref({
	labelWidth: '120px',
	span: 6,
	offset: 0,
	type: 'submit',
});
const types = {
	'1': decCardListLetter,
	'2': decCardListOther,
	'3': physicsFilesList,
	'4': leaseFilesList,
	'5': govFilesList,
};

//弹窗相关数据
const dialogTitle = ref('');
const dialogTableVisibleF = ref(false);
const searchDefault = ref({});

const searchData = ref({});
//表格显隐
const isUsePublic = ref(false);
const isProduceData = ref(false);
const isUseComponent = ref(false);
const isShareComponent = ref(false);
//获取子组件实例
const irsForm = ref();
const irsForm2 = ref();
const irsFormPhysics = ref();
const irsFormLease = ref();
const irsFormGov = ref();
const irsForm3 = ref();
const irsForm4 = ref();
const irsForm5 = ref();
const irsForm6 = ref();
const irsForm7 = ref();
const irsForm8 = ref();
const addNewTable = () => {
	dialogTitle.value = '新增拟使用数据';
	dialogTableVisibleF.value = true;
};
//黄色表格1
const TableFormInput1 = ref(false);
//黄色表格2
const TableFormInput2 = ref(false);
const addNewTableList1 = ref([]);
const addNewTableList2 = ref([]);
const classificationType = ref('');
const hyCard1 = ref({
	title: '',
});
const hyCard2 = ref({
	title: '云资源信息',
});
const hyCard3 = ref({
	title: '数据资源信息',
});
const hyCard4 = ref({
	title: '组件资源信息（发布端选择渝快政、渝快办，则必须勾选渝快政、渝快办相关统一类组件）',
});
const hyCard5 = ref({
	title: '资源硬件信息',
});
const hyCard6 = ref({
	title: '驾驶舱建设',
});
const hyCard7 = ref({
	title: '附件',
});
const editableTabsValue = ref('1');
const editableTabs = ref([
	{
		label: '',
		name: '1',
	},
]);

const searchFields1 = ref({
	irsName: {
		type: 'input',
		label: '应用名称',
		placeholder: '请输入应用名称',
		span: 8,
		disabled: true,
		required: true,
	},
	irsCode: {
		type: 'input',
		label: '应用编码',
		placeholder: '请输入应用编码',
		span: 8,
		required: true,
		disabled: true,
	},
	irsType: {
		type: 'select',
		label: '应用类型',
		required: true,
		span: 8,
		options: [],
	},
	developType: {
		type: 'tag',
		label: '开发模式',
		span: 8,
		required: true,
		options: [],
	},
	throughLevel: {
		type: 'tag',
		label: '贯通层级',
		required: true,
		span: 8,
		options: [],
	},
	businessDomain: {
		type: 'textarea',
		label: '业务领域',
		placeholder: '请输入业务领域',
		// disabled:true,
		maxlength: 1000,
		rows: 3,
		span: 24,
		required: true,
	},
	synergy: {
		type: 'select',
		label: '是否业务协同',
		required: true,
		span: 8,
		options: [],
		change(e) {
			searchFields1.value.synergyStructure.type = e == '1' ? 'tag' : '';
			searchFields1.value.synergyDescription.type = e == '1' ? 'textarea' : '';
		},
	},
	synergyStructure: {
		type: '',
		label: '业务协同结构',
		required: true,
		span: 8,
		rules: [{ required: true, message: '请选择业务协同结构', trigger: 'blur' }],
		options: [],
	},
	synergyDescription: {
		type: '',
		label: '业务协同描述',
		placeholder: '请输入业务协同描述',
		maxlength: 1000,
		// disabled:true,
		rows: 3,
		span: 24,
		required: true,
	},
	userRange: {
		type: 'tag',
		label: '用户范围',
		required: true,
		rows: 3,
		span: 8,
		options: [],
	},
	protectionLevel: {
		type: 'select',
		label: '等保级别',
		span: 8,
		required: true,
		rules: [{ required: true, message: '请选择等保级别', trigger: 'blur' }],
		options: [],
		change(e) {
			searchFields1.value.secretReview.type = e == '3' || e == '4' || e == '5' ? 'select' : '';
		},
	},
	secretReview: {
		type: '',
		label: '是否需要密评',
		span: 8,
		required: true,
		options: [],
		change(e) {
			searchFields1.value.secretLevel.type = e == '1' ? 'select' : '';
		},
	},
	secretLevel: {
		type: '',
		label: '密评等级',
		span: 8,
		required: true,
		options: [],
	},
	domestic: {
		type: 'select',
		label: '是否国产化',
		span: 8,
		required: true,
		options: [],
	},
});
const searchFieldsCloudType = ref({
	cloudType: {
		type: 'tag',
		label: '选择云资源类型（可多选）',
		required: true,
		span: 8,
		options: [],
		change(e) {
			isPhysics.value = e.includes('3') ? true : false;
			isLease.value = e.includes('4') ? true : false;
			isGov.value = e.includes('5') ? true : false;
		},
	},
});
const searchFieldsPhysics = ref({
	physics: {
		type: 'textarea',
		label: '物理服务器（或集群）申请依据',
		rows: 3,
		span: 22,
		maxlength: 1000,
		required: true,
	},
});
const searchFieldsLease = ref({
	lease: {
		type: 'textarea',
		label: '租赁互联网云资源申请依据',
		maxlength: 1000,
		rows: 3,
		span: 22,
		required: true,
	},
});
const searchFieldsGov = ref({
	gov: {
		type: 'textarea',
		label: '政务私有云申请依据',
		maxlength: 1000,
		rows: 3,
		span: 22,
		required: true,
	},
});
const searchFields3 = ref({
	usePublic: {
		type: 'select',
		label: '是否使用公共数据',
		span: 8,
		required: true,
		options: [],
		change(e) {
			isUsePublic.value = e == '1' ? true : false;
		},
	},
});
const searchFields4 = ref({
	produceData: {
		type: 'select',
		label: '是否产生数据',
		span: 8,
		required: true,
		options: [],
		change(e) {
			isProduceData.value = e == '1' ? true : false;
			if (e == '0') {
				deleteRow1(0);
			}
		},
	},
});
const searchFields5 = ref({
	useComponent: {
		type: 'select',
		label: '是否使用能力组件',
		span: 8,
		required: true,
		options: [],
		change(e) {
			isUseComponent.value = e == '1' ? true : false;
		},
	},
});
const searchFields9 = ref({
	shareComponent: {
		type: 'select',
		label: '是否共享组件',
		span: 8,
		required: true,
		options: [],
		change(e) {
			isShareComponent.value = e == '1' ? true : false;
			if (e == '0') {
				deleteRow2(0);
			}
		},
	},
});
const searchFields6 = ref({
	hardware: {
		type: 'select',
		label: '是否涉及硬件采购',
		span: 8,
		required: true,
		options: [],
		change(e) {
			searchFields6.value.hardwareType.type = e == '1' ? 'textarea' : '';
		},
	},
	hardwareType: {
		type: '',
		label: '具体采购的硬件类型',
		maxlength: 1000,
		rows: 3,
		span: 24,
		required: true,
	},
	strong: {
		type: 'select',
		label: '是否与该应用强相关',
		span: 8,
		required: true,
		options: [],
		change(e) {
			searchFields6.value.relevance.type = e == '1' ? 'textarea' : '';
		},
	},
	relevance: {
		type: '',
		label: '关联描述',
		maxlength: 1000,
		rows: 3,
		required: true,
		span: 24,
	},
});
const searchFields7 = ref({
	cockpit: {
		type: 'select',
		label: '是否涉及驾驶舱建设',
		span: 8,
		required: true,
		options: [],
		change(e) {
			searchFields7.value.budget.type = e == '1' ? 'inputFunny' : '';
		},
	},
	budget: {
		type: '',
		label: '预计费用金额（万元）',
		span: 8,
		required: true,
	},
});
const searchFields = ref({});
const tableConfig1 = ref({
	defaultData: [],
});
const tableConfig2 = ref({
	defaultData: [],
});
//申报时提交的数据汇总
const dataList = ref({});
const fileUploadSet = () => {
	let letterArr = []; //正式书面函
	let otherArr = []; //其他信息
	let govFilesArr = []; //物理服务器（或集群）申请依据佐证材料
	let leaseFilesArr = []; //租凭互联网云资源佐证材料
	let physicsFilesArr = []; //政务私有云佐证材料
	decCardListLetter.value.forEach((item) => {
		letterArr.push({
			name: item.name || item.response.data.name,
			url: item.url || item.response.data.url,
			id: item.id || item.response.data.id,
		});
	});

	decCardListOther.value.forEach((item) => {
		otherArr.push({
			name: item.name || item.response.data.name,
			url: item.url || item.response.data.url,
			id: item.id || item.response.data.id,
		});
	});

	physicsFilesList.value.forEach((item) => {
		physicsFilesArr.push({
			name: item.name || item.response.data.name,
			url: item.url || item.response.data.url,
			id: item.id || item.response.data.id,
		});
	});

	leaseFilesList.value.forEach((item) => {
		leaseFilesArr.push({
			name: item.name || item.response.data.name,
			url: item.url || item.response.data.url,
			id: item.id || item.response.data.id,
		});
	});

	govFilesList.value.forEach((item) => {
		govFilesArr.push({
			name: item.name || item.response.data.name,
			url: item.url || item.response.data.url,
			id: item.id || item.response.data.id,
		});
	});
	dataList.value = {
		irs: {
			irsId: 0,
			...irsForm.value[0]?.hyForm,
			...irsFormPhysics.value[0]?.hyForm,
			...irsFormLease.value[0]?.hyForm,
			...irsFormGov.value[0]?.hyForm,
			...irsForm3.value[0]?.hyForm,
			...irsForm4.value[0]?.hyForm,
			...irsForm5.value[0]?.hyForm,
			...irsForm6.value[0]?.hyForm,
			...irsForm7.value[0]?.hyForm,
			...irsForm8.value[0]?.hyForm,
			throughLevel: irsForm.value[0]?.hyForm.throughLevel && irsForm.value[0].hyForm.throughLevel.join(','),
			developType: irsForm.value[0]?.hyForm.developType && irsForm.value[0].hyForm.developType.join(','),
			cloudType: irsForm2.value[0]?.hyForm.cloudType && irsForm2.value[0].hyForm.cloudType.join(','),
			userRange: irsForm.value[0]?.hyForm.userRange && irsForm.value[0].hyForm.userRange.join(','),
			synergyStructure: irsForm.value[0]?.hyForm.synergyStructure && irsForm.value[0].hyForm.synergyStructure.join(','),
			summary: '子应用简介',
			budget: irsForm8.value[0]?.hyForm.budget - 0,
			physicsFiles: physicsFilesArr,
			leaseFiles: leaseFilesArr,
			govFiles: govFilesArr,
			letter: letterArr,
			other: otherArr,
			useInfo: [], //拟使用信息列表
			produceInfo: TableFormInputByData.value[0]?.info.data, //拟产生信息列表
			useComponentInfo: [], //使用组件信息列表
			shareComponentInfo: TableFormInputByDataZuJian.value[0]?.info.data, //共享组件信息列表
		},
	};
};

const confirm = async () => {
	if (!TableFormInputByData.value[0]) return;
	fileUploadSet();
	// if (isDeclareSubmit.value == true) {
	// 	const arr = [
	// 		irsForm.value[0]?.check(),
	// 		irsForm2.value[0]?.check(),
	// 		irsFormPhysics.value[0]?.check(),
	// 		irsFormLease.value[0]?.check(),
	// 		irsFormGov.value[0]?.check(),
	// 		irsForm3.value[0]?.check(),
	// 		irsForm4.value[0]?.check(),
	// 		irsForm5.value[0]?.check(),
	// 		irsForm8.value[0]?.check(),
	// 		irsForm6.value[0]?.check(),
	// 		irsForm7.value[0]?.check(),
	// 	];
	// 	const checked = await Promise.all(arr);
	// 	if (checked.every((item) => Boolean(item))) {
	// 		fileUploadSet();
	// 	}
	// } else {
	// 	fileUploadSet();
	// }
	// debugger;
};
const tableType = ref('');
const TableFormInputByData = ref();
const TableFormInputByDataZuJian = ref();
const openTable = (text?: any, data?: any) => {
	dialogTitle.value = '请选择关联应用';
	tableType.value = text;
	openVisible.value = true;
};
const closeDialog = () => {
	dialogTableVisibleF.value = false;
};
const closeTable = (data?: any) => {
	if (data) {
		addTableFormInputData.value.application = data.appName;
		addTableFormInputData.value.applicationCode = data.appCode;
		if (!editableTabs.value.length) {
			editableTabs.value.push({
				label: data.appName,
				name: '1',
			});
		}
		editableTabs.value[0].label = data.appName;
		searchDefault1.value.irsCode = data?.appCode;
		searchDefault1.value.irsName = data?.appName;
	}
	openVisible.value = false;
};
const deleteRow1 = (index: number) => {
	addNewTableList1.value.splice(index, 1);
};
const deleteRow2 = (index: number) => {
	addNewTableList2.value.splice(index, 1);
};
const valueList1 = ref([
	{
		value: '1',
		label: '数据库',
	},
	{
		value: '2',
		label: '图形图像',
	},
	{
		value: '3',
		label: '流媒体',
	},
	{
		value: '4',
		label: '电子文件',
	},
	{
		value: '5',
		label: '其他',
	},
]);
const valueList2 = ref([
	{
		value: '1',
		label: 'mySQL',
	},
	{
		value: '2',
		label: 'oracle',
	},
]);
const valueList3 = ref([
	{
		value: '1',
		label: 'Option1',
	},
	{
		value: '2',
		label: 'Option2',
	},
]);
const valueList4 = ref([
	{
		value: '1',
		label: 'Option1',
	},
	{
		value: '2',
		label: 'Option2',
	},
]);
const application = ref('');
const applicationCode = ref('');
const addTableFormInputData = ref({
	declareId: 0,
	resourceName: '',
	dataProvider: '',
	dataType: '2',
	application: '',
	applicationCode: '',
	coreFields: '',
	//下拉框
	classification: '',
	type: '',
	domain: '',
	level: '',
});
const addTableFormInput1 = () => {
	addNewTableList1.value = [addTableFormInputData.value];
};
const addTableFormInputDataZuJian = ref({
	dataType: '4',
	declareId: 0,
	componentName: '',
	componentUsageType: '推荐类组件',
	areas: '',
	businessArea: '',
	componentType: '',
	location: '',
	introduction: '',
});
const addTableFormInput2 = () => {
	addNewTableList2.value = [addTableFormInputDataZuJian.value];
};
const logList = () => {
	// console.log(TableFormInputByData.value[0].info.data);
};
const handleTabsEdit = (targetName: TabPaneName | undefined) => {
	const tabs = editableTabs.value;
	let activeName = editableTabsValue.value;
	editableTabsValue.value = activeName;
	editableTabs.value = tabs.filter((tab) => tab.name !== targetName);
	//移除时候清空数据
	dataList.value = {};
};
onMounted(() => {
	const { yes_no_type, app_business_type, protectionLevel_type, develop_type, through_level, synergy_structure, user_range, cloud_type } = useDict(
		'yes_no_type',
		'app_business_type',
		'protectionLevel_type',
		'develop_type',
		'through_level',
		'synergy_structure',
		'user_range',
		'cloud_type'
	);
	searchFields1.value.synergy.options = yes_no_type;
	searchFields1.value.secretReview.options = yes_no_type;
	searchFields1.value.domestic.options = yes_no_type;
	searchFields3.value.usePublic.options = yes_no_type;
	searchFields4.value.produceData.options = yes_no_type;
	searchFields5.value.useComponent.options = yes_no_type;
	searchFields9.value.shareComponent.options = yes_no_type;
	searchFields6.value.hardware.options = yes_no_type;
	searchFields6.value.strong.options = yes_no_type;
	searchFields7.value.cockpit.options = yes_no_type;
	searchFields1.value.irsType.options = app_business_type;
	searchFields1.value.protectionLevel.options = protectionLevel_type;
	searchFields1.value.secretLevel.options = protectionLevel_type;
	searchFields1.value.developType.options = develop_type;
	searchFields1.value.throughLevel.options = through_level;
	searchFields1.value.synergyStructure.options = synergy_structure;
	searchFields1.value.userRange.options = user_range;
	searchFieldsCloudType.value.cloudType.options = cloud_type;
});

//父组件方法
defineExpose({ dataList, confirm });
</script>

<style scoped lang="scss">
.HyCard-Card {
	margin-top: 10px;
}
.IRSbox {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	div,
	.button {
		margin-left: 10px;
	}
}
.isForm {
	margin-top: 10px;
}
.TableFormInput {
	margin-top: 10px;
}
.outDiv {
	display: flex;
	flex-wrap: nowrap;
}

.uploadDiv {
	width: 100%;
	span {
		display: inline-block;
		margin: 10px 0;
	}
}
.span-require {
	color: red;
}
.imglist {
	width: 100%;
	display: flex;
	justify-content: space-between;
}
.formThree {
	width: 100%;
}
.form-choose {
	width: 100%;
	display: flex;
	margin-top: 10px;
	.choose-right {
		width: 90%;
	}
}
.el-tab-pane {
	overflow: hidden;
}
</style>
